package com.codegenerate.demo.dto; /**
========= dto ==========
*/

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.codegenerate.demo.config.R;
import com.codegenerate.demo.entity.SysRole;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

public class SysRoleDto implements Serializable {
  private long id;

    int pageNum;
     int pageSize;
       public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

   public R validateUpdate(){
        if(this.getId()<0){
                   return R.failed("id 不能为空");
          }
        return R.ok(null);
    }


    List<AppFunDto> appFunDtoList;


    public List<AppFunDto> getAppFunDtoList() {
        return appFunDtoList;
    }

    public void setAppFunDtoList(List<AppFunDto> appFunDtoList) {
        this.appFunDtoList = appFunDtoList;
    }

    /**
            * 软删除
            */
            private long delState;
        

   
        
            /**
            * 权限逗号隔开
            */
            private String permitIds;
        

   
        
            /**
            * 角色
            */
            private String name;
        

   





    
           public long getId() {
             return id;
          }
          public void setId(long id) {
                 this.id = id;
          }   
   
           public long getDelState() {
             return delState;
          }
          public void setDelState(long delState) {
                 this.delState = delState;
          }   
   
           public String getPermitIds() {
             return permitIds;
          }
          public void setPermitIds(String permitIds) {
                 this.permitIds = permitIds;
          }   
   
           public String getName() {
             return name;
          }
          public void setName(String name) {
                 this.name = name;
          }   
   

 

        /**
        * build
        */
       public static SysRoleDto build(){
            SysRoleDto temp = new SysRoleDto();


            
                  temp.setId(0L);
            
                  temp.setDelState(1);
            
                  temp.setPermitIds("");
            
                  temp.setName("");
            

            return temp;
    }

    /**
        * setDefaultValue
        */
       public void  setDefaultValue(SysRoleDto temp){
            
                    if(this.id<=0){
                                temp.setId(0L);
                    }        
            
                    if(this.delState<=0){
                                temp.setDelState(1);
                    }        
            
                    if(StringUtils.isEmpty(this.permitIds)){
                                temp.setPermitIds("");
                    }        
            
                    if(StringUtils.isEmpty(this.name)){
                                temp.setName("");
                    }        
            
    }



    /**
        * dto2entity
        */
       public SysRole dto2entity(){
            var entity=SysRole.build();
            
                    if(this.id>0){
                       entity.setId(this.getId());
                    }        
            
                    if(this.delState>0){
                       entity.setDelState(this.getDelState());
                    }        
            
                    if(!StringUtils.isEmpty(this.permitIds)){
                       entity.setPermitIds(this.getPermitIds());
                    }        
            
                    if(!StringUtils.isEmpty(this.name)){
                       entity.setName(this.getName());
                    }        
            
            return entity;
        }

        

    public Page<SysRole> buildPage(){
            Page<SysRole> tempage = new Page<SysRole>();
            tempage.setCurrent(this.getPageNum()<=0?0:this.getPageNum());
            tempage.setSize(this.getPageSize()<=0?10:this.getPageSize());
            return tempage;
     }


}